jQuery(document).ready(function($) {
	$('a[rel=tooltip]').tooltip();
	$("#checkall_deleteid").click(function() {
		var status = this.checked;
		$("input[name='delete_id']").each(function() {
			this.checked = status;
		});
	});
	$('.popup-tooltip').popover({
		delay : {
			show : 100,
			hide : 100
		},
		trigger : 'hover'
	});
	$('.form-actions button[type=submit]').click(function() {
		$('html, body').animate({
			scrollTop : 0
		}, 500);
	});

	// Lazy load image
	$("img.lazy").lazyload();
});

dashboard.admin = {
	action : {
		deleteAll : function(table) {
			$("#notification").show();
			var listId = "";
			$("input[name='delete_id']").each(function() {
				if (this.checked)
					listId = listId + "," + this.value;
			});
			listId = listId.substr(1);
			if (listId == "") {
				alert("Please choose one record to delete!");
				return;
			}
			hoi = confirm("Are you sure to delete all selected record?");
			if (hoi == true) {
				data = 'listId=' + listId;
				jQuery.ajax({
					type : 'POST',
					url : table + '/delete',
					data : data,
					dataType : 'json',
					success : function(result) {
						//location.reload();
						$("#notification").hide();
						console.log(result);
					}
				});
			}
			return false;
		}
	},
};